<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
    <body>
        <?php foreach($query1->result() as $rows_ques){
            $limtit_time=$rows_ques->TRAP;
            $limit_array=  explode(',', $limtit_time);
            $limit1=$limit_array[0];
            $limit2=$limit_array[1];
            $limit=$limit1+$limit2;
        } ?>
         <script>
                   limitTime = "<?= $limit ?>";
          
            
            
            var i = 0;
            var myVar = setInterval(function(){
                i++;
                document.getElementById("countdown").innerHTML = limitTime - i;         //chuyen vao <p id="countdown"></p>
                 document.getElementById("count").value = limitTime - i;        // chuyen vao  <input id="count" name="time" type="hidden">
                 
                 
                //$('input#countdown').val(limitTime - i);    
                if(i==limitTime){
                   document.getElementById("jumptoIndex1").submit();        //click nut submit
                    clearInterval(myVar);
                    
                }
            },1000);    // 1000 = 1s ;
           


        </script>
        
        <h1><p id="countdown"></p></h1>
        <form  id="jumptoIndex2" method="post" action="index1.php">
        
        </form>
<div class="post">
    <div class="entry">
        <div class="test">
            <?php 
                    foreach($query1->result() as $rows_ques){
                    $id=$rows_ques->id_question;
                    $id_back=$rows_ques->id_question-1;
                    $id_next=$rows_ques->id_question+1;?>
            <div id="q_question">
                <h3><?=$rows_ques->id_question?>></h3><h2>&nbsp<?=$rows_ques->qs?></h2>
            </div>
            </br>
            <div id="q_answer">
                <?php 
               
                if($id==$max_ques)
                            {?>
                            <form id="jumptoIndex1" action="<?php echo base_url().'tester/submit_x2/'.$id;?>" method="post" >
                            <?php }
                            else
                            {?>
                            <form id="jumptoIndex1" action="<?php echo base_url().'tester/sub_ques_x2/'.$id_next;?>" method="post">
                            <?php }?>
                <table>
                    <tr>
                        <td><input type="hidden" name="txtID" value="<?=$id_next-1?>"></td>
                        <td><input id="count" name="time" type="hidden">
                        </td>
                    </tr>
                    <tr>
                        <td><input type="radio" name="select" value="S(1)">&nbsp<?=$rows_ques->s2?></td>
                        <td><input type="radio" name="select" value="S(2)">&nbsp<?=$rows_ques->s2?></td>
                    </tr>
                   
                    <tr>
                        <td><input type="radio" name="select" value="S(3)">&nbsp<?=$rows_ques->s3?></td>
                        <td><input type="radio" name="select" value="S(4)">&nbsp<?=$rows_ques->s4?></td>
                    </tr>   
                    <tr>
                        <td><input type="radio" name="select" value="S(5)">&nbsp<?=$rows_ques->s5?></td>
                        <td><input type="radio" name="select" value="S(6)">&nbsp<?=$rows_ques->s6?></td>
                    </tr>
                    <tr>
                        <td align="right">
                            <?php if($id==$max_ques)
                            {?>
                                <input type="submit" name="next" value="Submit" />
                            <?php }
                            else
                            {
                            ?>
                            <input type="submit" name="next" value="Next" />
                            <?php }?>
                        </td>
                    </tr>
                </table>
                </form>
            </div>
            <div>
                
            </div>
            <?php }?>
        </div>
    </div>
</div>
            </body>
</html>
